function adPanelDurability_OnEnter()

   if not adPanel_IsDragging then
	adPanelTooltip:ClearAllAnchors();
	adPanelTooltip:SetAnchor("TOPLEFT", "BOTTOMLEFT", "adPanelDurability", 0, 0);
	adPanelTooltip:SetText("|cffbb6633adPanelDurability|r");

	for index = 1, 19 do
		local cur,max,itemName,curfull,maxfull = GetInventoryItemDurable("player", index)
		if max ~= 0 then
			local pct = math.ceil((cur/max)*1000)/10

			if pct < 10 then textColor = "ff0000";
			elseif pct < 25 then textColor = "ff8800";
			elseif pct < 50 then textColor = "ffff00";
			else textColor = "00ff00"; end
	
		        adPanelTooltip:AddLine(itemName .. ": "..pct);

		end	
	end
   end
end

function adPanelDurability_OnUpdate()
	local avg = 0
	local lowest = 1000
	local num_items = 0
	for index = 1, 19 do
		local cur,max,itemName,curfull,maxfull = GetInventoryItemDurable("player", index);
		if max ~= 0 then
			local pct = math.ceil((cur/max)*1000)/10;
			if pct < lowest then lowest = pct end;
			avg = avg + pct
			num_items = num_items + 1
		end	
	end
	if items == 0 then return end;
	avg = math.ceil((avg/num_items)*10)/10

	local textColor;
	
	if lowest < 10 then textColor = "ff0000";
	elseif lowest < 25 then textColor = "ff8800";
	elseif lowest < 50 then textColor = "ffff00";
	else textColor = "00ff00"; end
	
	adPanelDurabilityText:SetText("|cff"..textColor..lowest.."%|r/"..avg..'%');
end
